package io.imp.modules.itcs.controller;

import java.util.Arrays;
import java.util.Map;

import io.imp.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.imp.modules.itcs.entity.CppRoadConfEntity;
import io.imp.modules.itcs.service.CppRoadConfService;
import io.imp.common.utils.PageUtils;
import io.imp.common.utils.R;



/**
 * 路方配置表
 *
 * @author wanghui
 * @email ${email}
 * @date 2019-04-26 14:16:42
 */
@RestController
@RequestMapping("itcs/cpproadconf")
public class CppRoadConfController {
    @Autowired
    private CppRoadConfService cppRoadConfService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("itcs:cpproadconf:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cppRoadConfService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("itcs:cpproadconf:info")
    public R info(@PathVariable("id") String id){
        CppRoadConfEntity cppRoadConf = cppRoadConfService.getById(id);

        return R.ok().put("cppRoadConf", cppRoadConf);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("itcs:cpproadconf:save")
    public R save(@RequestBody CppRoadConfEntity cppRoadConf){
        cppRoadConfService.save(cppRoadConf);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("itcs:cpproadconf:update")
    public R update(@RequestBody CppRoadConfEntity cppRoadConf){
        ValidatorUtils.validateEntity(cppRoadConf);
        cppRoadConfService.updateById(cppRoadConf);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("itcs:cpproadconf:delete")
    public R delete(@RequestBody String[] ids){
        cppRoadConfService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
